package com.cos.lession67.web.servlet;

import com.cos.lession67.common.Const;
import com.cos.lession67.entity.Emp;
import com.cos.lession67.servcies.EmpServices;
import com.cos.lession67.servcies.impl.EmpServicesImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: COS
 * @time: 2022/9/21 17:38
 * @description:
 */
@WebServlet("/emp")
public class EmpController extends BaseServlet {
    private EmpServices es = new EmpServicesImpl();
    public String doLogin(HttpServletRequest request, HttpServletResponse response){

        String ename = request.getParameter("ename");
        String pwd = request.getParameter("pwd");

        Emp emp = es.doLogin(ename,pwd);

        if (emp != null) {
            request.getSession().setAttribute("is_login", emp);
            return Const.REDIRECT+"/index.jsp";
        }else{
            return Const.REDIRECT+"/login.jsp";
        }
    }


}
